package com.flame.workflow.re.service;

import com.flame.workflow.re.entity.Form;
import com.flame.workflow.re.mapper.FormMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * flame_workflow_re_form 流程表单定义表
 *
 * @author 吴欣童
 * @since 2023-05-04 19:52:48
 */
@Service
public class FormService {

    @Autowired
    private FormMapper formMapper;

    public Form getForm(Long modelId, Integer modelVersion) {
        return formMapper.findById(modelId, modelVersion);
    }

    public void maintainForm(Form form) {
        Form dbForm = formMapper.findById(form.getModelId(), form.getModelVersion());
        if (dbForm != null) {
            formMapper.updateById(form);
        } else {
            formMapper.insert(form);
        }
    }
}
